package com.shanzmoo.merchant.server.api.web.member;

import com.shanzmoo.base.bean.PageRespBase;
import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.base.constant.e.LoginUserType;
import com.shanzmoo.db.module.member.domain.dto.CMemberRechargeRequestDTO;
import com.shanzmoo.db.module.member.domain.query.CMemberCardBillQuery;
import com.shanzmoo.db.module.member.domain.query.CMemberCouponQuery;
import com.shanzmoo.db.module.member.domain.vo.*;
import com.shanzmoo.db.module.merchant.domain.dto.MerchantOrderSaveDto;
import com.shanzmoo.db.module.merchant.domain.vo.MerchantOrderVo;
import com.shanzmoo.merchant.server.api.aspect.UserAuth;
import com.shanzmoo.merchant.server.api.manager.member.MemberManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Slf4j
@Api(tags = "会员")
@RestController
@RequestMapping("/member")
public class MemberController {
    @Autowired
    private MemberManager memberManager;

    @ApiOperation(value = "会员详情(名称，积分，余额，卡号)")
    @GetMapping("/detail")
    @UserAuth({LoginUserType.SH_HUIYUAN})
    public SHttpResponse<CMemberDetailVO> detail() {
        return memberManager.detail();
    }
    @ApiOperation(value = "充值活动列表(满多少 减多少)")
    @GetMapping("/recharge/activity/list")
    @UserAuth({LoginUserType.SH_HUIYUAN,LoginUserType.SH_TEMP})
    public SHttpResponse<List<CMemberRechargeActivityVO>> rechargeActivityList() {
        return memberManager.rechargeActivityList();
    }
    @ApiOperation(value = "充值")
    @PostMapping("/recharge")
    @UserAuth({LoginUserType.SH_HUIYUAN})
    public SHttpResponse<Object> recharge(@RequestBody CMemberRechargeRequestDTO requestDTO) {
        //Object obj = memberManager.recharge(requestDTO);
        return SHttpResponse.ok(null);
    }
    @ApiOperation(value = "我的优惠券")
    @PostMapping("/coupon/list")
    @UserAuth({LoginUserType.SH_HUIYUAN})
    public SHttpResponse<PageRespBase<CMemberCouponVO>> couponList(@RequestBody CMemberCouponQuery query) {
        SHttpResponse<PageRespBase<CMemberCouponVO>> res = memberManager.couponList(query);
        return res;
    }
    @ApiOperation(value = "会员卡账单")
    @PostMapping("/card/bill/list")
    @UserAuth({LoginUserType.SH_HUIYUAN})
    public SHttpResponse<PageRespBase<CMemberAccountRecordVO>> cardBillList(@RequestBody CMemberCardBillQuery query) {
        return  memberManager.cardBillList(query);
    }
    @ApiOperation(value = "我的积分")
    @PostMapping("/score/list")
    @UserAuth({LoginUserType.SH_HUIYUAN})
    public SHttpResponse<CMemberScorePageVO<CMemberScoreRecordVO>> scoreList(@RequestBody CMemberCardBillQuery query) {
        return memberManager.scoreList(query);
    }
    @ApiOperation(value = "根据金额获取可参加的活动，可使用优惠券")
    @GetMapping("/get-activity")
    @UserAuth({LoginUserType.SH_HUIYUAN})
    public SHttpResponse<CMemberActivityByAmtVO> getActivity(@RequestParam(required = true) Long orderAmt) {
        return memberManager.getActivity(orderAmt);
    }
    @ApiOperation(value = "充值时根据金额获取可参加的活动")
    @GetMapping("/recharge/get-activity")
    @UserAuth({LoginUserType.SH_TEMP,LoginUserType.SH_HUIYUAN})
    public SHttpResponse<CMemberRechargeActivityVO> getRechargeActivity(@RequestParam(required = true) Long orderAmt) {
        return memberManager.getRechargeActivity(orderAmt);
    }
    @ApiOperation(value = "我的会员卡")
    @GetMapping("/card/list")
    @UserAuth({LoginUserType.SH_HUIYUAN})
    public SHttpResponse<CMemberRechargeActivityVO> getCardList() {
        return null;
    }
}
